<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" type="text/javascript">

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getBatch(groupId) {		
		
		var strURL="findState.php?group="+groupId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
	function AjaxFunction(email)
	{
		//alert(email);
		var url="validation.php";
		url=url+"?email="+email;
		url=url+"&sid="+Math.random();
		var reqEmqil = getXMLHTTP();
		
		if (reqEmqil) {
			
			reqEmqil.onreadystatechange = function() {
				if (reqEmqil.readyState == 4) {
					// only if "OK"
										
						document.getElementById("msg").innerHTML=reqEmqil.responseText;						
					
				}				
			}			
			reqEmqil.open("GET", url, true);
			reqEmqil.send(null);
		}
	 
	}
	
</script>
</head>
<body>


<form method="post" action="" name="form1">
Any email address <input type=text name=email onBlur="AjaxFunction(this.value)" /> <div id="msg"></div>
<br>
<input type=hidden value=test name=todo>
<table width="60%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="150">Group</td>
    <td  width="150"><select name="group" onChange="getBatch(this.value)">
	<option value="">---</option>
	<option value="1">BBA</option>
	<option value="2">MBA</option>
    <option value="3">EMBA</option>
    <option value="4">Fellow</option>
    <option value="5">Honorary</option>
    <option value="6">Associate</option>
        </select></td>
  </tr>
  <tr style="">
    <td>Batch</td>
    <td ><div id="statediv"><select name="batch" >
	<option>---</option>
        </select></div></td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>
